package com.wutianyi.module.company;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

@SuppressWarnings("serial")
public class Company implements Serializable
{
    private String description;
    private String gmtCreate;
    private String gmtModified;
    private String name;
    private String nameEn;
    private String companyId;
    private int exCategoryId;

    public Company(String companyId, String description, int exCategoryId, String gmtCreate, String gmtModified,
            String name, String nameEn)
    {
        this.companyId = companyId;
        this.description = description;
        this.exCategoryId = exCategoryId;
        this.gmtCreate = gmtCreate;
        this.gmtModified = gmtModified;
        this.name = name;
        this.nameEn = nameEn;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public String getGmtCreate()
    {
        return gmtCreate;
    }

    public void setGmtCreate(String gmtCreate)
    {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtModified()
    {
        return gmtModified;
    }

    public void setGmtModified(String gmtModified)
    {
        this.gmtModified = gmtModified;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getNameEn()
    {
        return nameEn;
    }

    public void setNameEn(String nameEn)
    {
        this.nameEn = nameEn;
    }

    public String getCompanyId()
    {
        return companyId;
    }

    public void setCompanyId(String companyId)
    {
        this.companyId = companyId;
    }

    public int getExCategoryId()
    {
        return exCategoryId;
    }

    public void setExCategoryId(int exCategoryId)
    {
        this.exCategoryId = exCategoryId;
    }

    public static void main(String[] args) throws IOException, ClassNotFoundException
    {
        UUID uuid = UUID.randomUUID();
        String description = "This page describes exactly what Java code the protocol buffer compiler generates for any given protocol definition. You should read the language guide before reading this document.";
        SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd : hh:mm:ss");
        String gmtCreate = dateformat.format(new Date());
        String gmtModified = dateformat.format(new Date());
        String name = "This page describes exactly what Java code the protocol buffer compiler generates for any given protocol definition. You should read the language guide before reading this document.";
        String nameEn = "English";

        Company company = new Company(uuid.toString(), description, 1, gmtCreate, gmtModified, name, nameEn);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        long start = System.currentTimeMillis();
        oos.writeObject(company);
        System.out.println("use times: " + (System.currentTimeMillis() - start));
        System.out.println(baos.toByteArray().length);
        
        start = System.currentTimeMillis();
        ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        Company c = (Company) inputStream.readObject();
        System.out.println("use times: " + (System.currentTimeMillis() - start));
    }
}
